package br.com.games.pyx;

import org.anddev.andengine.engine.Engine;
import org.anddev.andengine.engine.camera.ZoomCamera;
import org.anddev.andengine.engine.options.EngineOptions;
import org.anddev.andengine.engine.options.EngineOptions.ScreenOrientation;
import org.anddev.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy;
import org.anddev.andengine.entity.scene.Scene;
import org.anddev.andengine.entity.scene.background.ColorBackground;
import org.anddev.andengine.entity.sprite.AnimatedSprite;
import org.anddev.andengine.entity.util.FPSLogger;
import org.anddev.andengine.input.touch.detector.SurfaceScrollDetector;
import org.anddev.andengine.opengl.texture.Texture;
import org.anddev.andengine.opengl.texture.TextureOptions;
import org.anddev.andengine.opengl.texture.region.TextureRegionFactory;
import org.anddev.andengine.opengl.texture.region.TiledTextureRegion;
import org.anddev.andengine.ui.activity.BaseGameActivity;

import br.com.games.pyx.atores.Ator;
import br.com.games.pyx.atores.game.Toupety;
import br.com.games.pyx.scenes.Cenario;
import br.com.games.pyx.singleton.FabricaRecursos;

public class Main extends BaseGameActivity {

	public static final int CAMERA_WIDTH = 800;
	public static final int CAMERA_HEIGHT = 600;
	
	private static final String TAG = "ToupetyGame";
	
	private ZoomCamera mCamera;
	private Texture mTexture;
	private TiledTextureRegion mBallTextureRegion;
	private TiledTextureRegion andandoDirRegion, andandoLefRegion;
	private SurfaceScrollDetector mScrollDetector; 
//	private TMXTiledMap mTMXTiledMap;
	
	@Override
	public Engine onLoadEngine() {
		this.mCamera = new ZoomCamera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
		
		FabricaRecursos.get().setMainContext(this);
		FabricaRecursos.get().setCamera(mCamera);
		
		Engine engine = new Engine(new EngineOptions(true, ScreenOrientation.LANDSCAPE, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), this.mCamera));
		
		FabricaRecursos.get().setEngine(engine);
		
		return engine; 
	}

	@Override
	public void onLoadResources() {
		//FabricaRecursos.get().loadResourcers();
	}

	@Override
	public Scene onLoadScene() {
		this.mEngine.registerUpdateHandler(new FPSLogger());
		 
		Cenario cena = new Cenario();
		
		cena.loadResourcers("");
		cena.setBackground(new ColorBackground(0.74313724f, 0.8333333f, 0.8568627f));
		 
		return cena;
	}

	@Override
	public void onLoadComplete() {
//		final Scene scene = this.mEngine.getScene();
//		Toupety toupety = new Toupety();
//
//		
//		toupety.init();
//		toupety.setPosition(200,100);
//		toupety.getActual().animate(80);
//		
//		toupety.setActual(1);
//		
//		scene.getLastChild().attachChild(toupety);
	}

}